<?php
    require 'phpincludes/twitterconfig.php';
    require 'phplibs/rss_php.php';
    
    $twitterfeedurl = 'https://api.twitter.com/1/statuses/user_timeline.rss?screen_name='.$twittername;

    // load some RSS file
    $rss = new rss_php();
    $rss->load($twitterfeedurl);
    
    $twitterfeed = $rss->getItems();

    if(count($twitterfeed) > 0){
        foreach($twitterfeed as $item){
            $pluspos = strpos($item['pubDate'], '+');
            $itemdisplaydate = substr($item['pubDate'], 0, $pluspos - 1);
            
            $colonpos = strpos($item['description'], ':');
            $itemdisplaydescription = substr($item['description'], $colonpos + 2);
            
            echo '<div class="twitterfeeditem">'
                    .'<div class="twitterfeeditempic">'
                        .'<a href="'.$twitterpageurl.'" target="_BLANK" />'
                            .'<img src="'.$twitterpagepicurl.'" alt="'.$twittername.'" />'
                        .'</a>'
                    .'</div>'
                    .'<div class="twitterfeeditemtexts">'
                        .'<div class="twitterfeeditemname">'
                            .'<a href="'.$twitterpageurl.'" target="_BLANK" />'
                                .'<span class="twitterfullname">'.$twitterfullname.'</span> <span class="twittername">@'.$twittername.'</span>'
                            .'</a>'
                        .'</div>'
                        .'<div class="twitterfeeditemdescription">'.$itemdisplaydescription.'</div>'
                        .'<div class="twitterfeeditemdate">'.$itemdisplaydate.'</div>'
                    .'</div>'
                  .'</div>';
        }
    }
    else{
        echo 'Could not connect to Twitter';
    }
?>
